package com.cdkey;

import java.io.File;
import java.io.FileInputStream;

import com.common.utils.IOUtils;
import com.common.utils.JsonUtil;
import com.jfinal.kit.PathKit;

public class WXConfig {

	public class Config
	{
		String welcome;
		String error;
		public String getWelcome() {
			return welcome;
		}
		public void setWelcome(String welcome) {
			this.welcome = welcome;
		}
		public String getError() {
			return error;
		}
		public void setError(String error) {
			this.error = error;
		}
		
	}

	private Config config;
	
	public Config getConfig() {
		return config;
	}


	private static  class Honder 
	{
		public static final WXConfig mConfig = new WXConfig();
	}
	
	public static WXConfig getInstace()
	{
		return Honder.mConfig;
	}
	

	private WXConfig()
	{
		 String ehcacheConf = PathKit.getWebRootPath() + File.separator + "WEB-INF" + File.separator + "wx_config.json"; 
		 FileInputStream fin = null;
		try {
			 fin = new FileInputStream(ehcacheConf);
			String josnString = IOUtils.toString(fin);
			config = JsonUtil.fromJson(josnString, Config.class);
			 
		} catch (Exception e) {
			e.printStackTrace();
		}finally
		{
			IOUtils.closeQuietly(fin);
		}
	}

}
